<HTML><HEAD>
<TITLE>netwib doc_html (version 5.39.0)</TITLE>
</HEAD><BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<H2><A HREF="../../index.html">main index</A></H2>
<H2><A HREF="../dat.html">section index</A></H2><HR><BR>
<PRE>

<FONT COLOR="#880000">/*-------------------------------------------------------------*/</FONT>
<FONT COLOR="#880000"><B>/***************************************************************
 * A <FONT COLOR="#000088">netwib_hash_index</FONT> is used to loop through a hash.         *
 *                                                             *
 * When the hash is only read, several indexes                 *
 * can simultaneously loop through the hash.                   *
 *                                                             *
 * However, when the hash is edited, strange behavior can      *
 * occur when a <FONT COLOR="#000088">netwib_hash_index_xyz</FONT> function is called,      *
 * depending on function used to edit the hash:                *
 *  - netwib_hash_contains,                                    *
 *    netwib_hash_value,                                       *
 *    <FONT COLOR="#000088">netwib_hash_index_next</FONT>                                   *
 *    netwib_hash_index_this_value,                            *
 *    netwib_hash_index_this_replace,                          *
 *    netwib_hash_index_this_del:                              *
 *      No problem.                                            *
 *  - netwib_hash_add,                                         *
 *    netwib_hash_add_hash_criteria:                           *
 *      The added item(s) may be returned or not returned,     *
 *      depending on the (unpredictable) insertion position    *
 *      relative to the index position.                        *
 *  - netwib_hash_del,                                         *
 *    netwib_hash_del_criteria:                                *
 *      You should not use them because if the item pointed by *
 *      the index is deleted, it will cause an access to freed *
 *      memory. You may use them only if you are sure to not   *
 *      delete the current item.                               *
 *      However, after netwib_hash_index_this_del, you must    *
 *      not use them because there is not way to know if they  *
 *      will delete internal items.                            *
 ***************************************************************/</B></FONT>

<FONT COLOR="#880000">/*-------------------------------------------------------------*/</FONT>
typedef struct <FONT COLOR="#000088">netwib_hash_index</FONT> <FONT COLOR="#000088">netwib_hash_index</FONT>;

<FONT COLOR="#880000">/*-------------------------------------------------------------*/</FONT>
<FONT COLOR="#880000">/* Name : netwib_hash_index_init
   Description :
     Initialize a <FONT COLOR="#000088">netwib_hash_index</FONT> used to loop through
     a netwib_hash.
   Input parameter(s) :
   Input/output parameter(s) :
   Output parameter(s) :
     **pphashindex : <FONT COLOR="#000088">netwib_hash_index</FONT> allocated and initialized
   Normal return values :
     <FONT COLOR="#000044">NETWIB_ERR_OK</FONT> : ok
*/</FONT>
<FONT COLOR="#000088">netwib_err</FONT> <B>netwib_hash_index_init</B>(<FONT COLOR="#000088">netwib_consthash</FONT> *phash,
                                  <FONT COLOR="#000088">netwib_hash_index</FONT> **pphashindex);

<FONT COLOR="#880000">/*-------------------------------------------------------------*/</FONT>
<FONT COLOR="#880000">/* Name : netwib_hash_index_close
   Description :
     Close a netwib_hashindex.
   Input parameter(s) :
   Input/output parameter(s) :
     **pphashindex : <FONT COLOR="#000088">netwib_hash_index</FONT> closed
   Output parameter(s) :
   Normal return values :
     <FONT COLOR="#000044">NETWIB_ERR_OK</FONT> : ok
*/</FONT>
<FONT COLOR="#000088">netwib_err</FONT> <B>netwib_hash_index_close</B>(<FONT COLOR="#000088">netwib_hash_index</FONT> **pphashindex);

<FONT COLOR="#880000">/*-------------------------------------------------------------*/</FONT>
<FONT COLOR="#880000">/* Types to control a <FONT COLOR="#000088">netwib_hash_index</FONT> */</FONT>
typedef enum {
  <FONT COLOR="#000044">NETWIB_HASH_INDEX_CTLTYPE_REWIND</FONT> = 1,  <FONT COLOR="#880000">/* position at beginning */</FONT>
  <FONT COLOR="#000044">NETWIB_HASH_INDEX_CTLTYPE_INDEX</FONT>        <FONT COLOR="#880000">/* reset with index pos */</FONT>
} <FONT COLOR="#000088">netwib_hash_index_ctltype</FONT>;
<FONT COLOR="#880000">/* Those functions permit to set/get parameters (pointer and
   integer) about a netwib_hash_index. It should not be used directly,
   but by the defines.
*/</FONT>
<FONT COLOR="#000088">netwib_err</FONT> <B>netwib_hash_index_ctl_set</B>(<FONT COLOR="#000088">netwib_hash_index</FONT> *phashindex,
                                     <FONT COLOR="#000088">netwib_hash_index_ctltype</FONT> type,
                                     <FONT COLOR="#000088">netwib_ptr</FONT> p,
                                     <FONT COLOR="#000088">netwib_uint32</FONT> ui);
<FONT COLOR="#000088">netwib_err</FONT> <B>netwib_hash_index_ctl_get</B>(<FONT COLOR="#000088">netwib_hash_index</FONT> *phashindex,
                                     <FONT COLOR="#000088">netwib_hash_index_ctltype</FONT> type,
                                     <FONT COLOR="#000088">netwib_ptr</FONT> p,
                                     <FONT COLOR="#000088">netwib_uint32</FONT> *pui);

<FONT COLOR="#880000">/*-------------------------------------------------------------*/</FONT>
<FONT COLOR="#880000">/* <FONT COLOR="#000088">netwib_err</FONT> f(<FONT COLOR="#000088">netwib_hash_index</FONT> *phashindex); */</FONT>
<FONT COLOR="#008800">#define <B>netwib_hash_index_ctl_set_rewind</B>(phashindex) <B>netwib_hash_index_ctl_set</B>(phashindex,<FONT COLOR="#000044">NETWIB_HASH_INDEX_CTLTYPE_REWIND</FONT>,NULL,0)</FONT>
<FONT COLOR="#880000">/* <FONT COLOR="#000088">netwib_err</FONT> f(<FONT COLOR="#000088">netwib_hash_index</FONT> *phashindex,<FONT COLOR="#000088">netwib_hash_index</FONT> *phashindexref);*/</FONT>
<FONT COLOR="#008800">#define <B>netwib_hash_index_ctl_set_index</B>(phashindex,phashindexref) <B>netwib_hash_index_ctl_set</B>(phashindex,<FONT COLOR="#000044">NETWIB_HASH_INDEX_CTLTYPE_INDEX</FONT>,phashindexref,0)</FONT>

<FONT COLOR="#880000">/*-------------------------------------------------------------*/</FONT>
<FONT COLOR="#880000">/* Name : netwib_hash_index_next_criteria
   Description :
     Get the next item in the hash.
   Input parameter(s) :
     pfunc_search : function used to match the item
   Input/output parameter(s) :
     *phashindex : netwib_hash_index
     pinfos : optional parameter (can be NULL) which will be
              used as the second parameter for *pfunc_search.
              This may be used to send information to *pfunc_search.
   Output parameter(s) :
     *pkey : found key
     *ppitem : found item
   Normal return values :
     <FONT COLOR="#000044">NETWIB_ERR_OK</FONT> : ok
     <FONT COLOR="#000044">NETWIB_ERR_DATAEND</FONT> : end of the hash reached
*/</FONT>
<FONT COLOR="#000088">netwib_err</FONT> <B>netwib_hash_index_next_criteria</B>(<FONT COLOR="#000088">netwib_hash_index</FONT> *phashindex,
                                           <FONT COLOR="#000088">netwib_hash_criteria_pf</FONT> pfunc_search,
                                           <FONT COLOR="#000088">netwib_ptr</FONT> pinfos,
                                           <FONT COLOR="#000088">netwib_buf</FONT> *pkey,
                                           <FONT COLOR="#000088">netwib_ptr</FONT> *ppitem);
<FONT COLOR="#008800">#define <B>netwib_hash_index_next</B>(phashindex,pkey,ppitem) <B>netwib_hash_index_next_criteria</B>(phashindex,NULL,NULL,pkey,ppitem)</FONT>

<FONT COLOR="#880000">/*-------------------------------------------------------------*/</FONT>
<FONT COLOR="#880000">/* Name : netwib_hash_index_this_value
   Description :
     Re-give the last value.
   Input parameter(s) :
   Input/output parameter(s) :
     *phashindex : netwib_hash_index
   Output parameter(s) :
     *pkey : found key
     *ppitem : found item
   Normal return values :
     <FONT COLOR="#000044">NETWIB_ERR_OK</FONT> : ok
*/</FONT>
<FONT COLOR="#000088">netwib_err</FONT> <B>netwib_hash_index_this_value</B>(<FONT COLOR="#000088">netwib_hash_index</FONT> *phashindex,
                                        <FONT COLOR="#000088">netwib_buf</FONT> *pkey,
                                        <FONT COLOR="#000088">netwib_ptr</FONT> *ppitem);

<FONT COLOR="#880000">/*-------------------------------------------------------------*/</FONT>
<FONT COLOR="#880000">/* Name : netwib_hash_index_this_del
   Description :
     Delete the last given value by a netwib_hash_index_next
     function.
   Input parameter(s) :
     eraseitem : if true, function pfunc_erase (set in
                 netwib_hash_init) is called to erase the
                 item located at position
   Input/output parameter(s) :
     *phashindex : netwib_hash_index
   Output parameter(s) :
   Normal return values :
     <FONT COLOR="#000044">NETWIB_ERR_OK</FONT> : ok
*/</FONT>
<FONT COLOR="#000088">netwib_err</FONT> <B>netwib_hash_index_this_del</B>(<FONT COLOR="#000088">netwib_hash_index</FONT> *phashindex,
                                      <FONT COLOR="#000088">netwib_bool</FONT> eraseitem);

<FONT COLOR="#880000">/*-------------------------------------------------------------*/</FONT>
<FONT COLOR="#880000">/* Name : netwib_hash_index_this_replace
   Description :
     Replace value, but keep the same key.
   Input parameter(s) :
     pitem : pointer to an allocated memory containing the item
     erasepreviousitem : if true, function pfunc_erase (set in
                         netwib_hash_init) is called to erase the
                         item previously located in the hash
   Input/output parameter(s) :
     *phashindex : netwib_hash_index
   Output parameter(s) :
   Normal return values :
     <FONT COLOR="#000044">NETWIB_ERR_OK</FONT> : ok
*/</FONT>
<FONT COLOR="#000088">netwib_err</FONT> <B>netwib_hash_index_this_replace</B>(<FONT COLOR="#000088">netwib_hash_index</FONT> *phashindex,
                                          <FONT COLOR="#000088">netwib_constptr</FONT> pitem,
                                          <FONT COLOR="#000088">netwib_bool</FONT> erasepreviousitem);
</PRE><BR><BR><HR><BR>
<H2><A HREF="../../index.html">main index</A></H2>
<H2><A HREF="../dat.html">section index</A></H2>
</BODY></HTML>
